package com.jxs.android.weiget;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.telecom.weixi.R;
import com.telecom.weixi.WeixiApplication;

public class PopMsg {

	public static void show(String msg, Integer... duration) {
		Context context = WeixiApplication.getApplication();
		final Toast toast = new Toast(context);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View contentView = inflater.inflate(R.layout.pop_msg_bar, null);
		((TextView) contentView.findViewById(R.id.alert_message)).setText(msg);
		toast.setView(contentView);
		if (null == duration) {
			toast.setDuration(1500);
		} else if (null != duration && duration.length == 1) {
			toast.setDuration(duration[0]);
		}
		toast.setGravity(Gravity.CENTER_VERTICAL, 0, 75);
		toast.show();
	}

	public static void show(int msgId, Integer... duration) {
		Context context = WeixiApplication.getApplication();
		show(context.getString(msgId), duration);
	}
}
